package com.xinwei.leetcode.链表;

import com.xinwei.linearExercise.LinkedList;

import javax.jnlp.ClipboardService;

public class ListNode {

    public int val;
    public ListNode next;

    public ListNode() {
    }

    public ListNode(int val) {
        this.val = val;
    }

    public ListNode(int val, ListNode next) {
        this.val = val;
        this.next = next;
    }

    @Override
    public String toString() {
        ListNode node = next;
        StringBuilder string = new StringBuilder();
        string.append("[").append(val);
        while (node != null){
            string.append(", "+node.val);
            node = node.next;
        }
        string.append("]");
        return string.toString();
    }
}
